<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>order管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

    <!-- 上传图片框样式，不使用上传组件可以删除此样式 -->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }

        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 150px;
            height: 70px;
            line-height: 150px;
            text-align: center;
        }

        .avatar {
            width: 150px;
            height: 70px;
            display: block;
        }

    </style>
</head>
<body class="hold-transition">
<div id="app">

    <div class="content-header">
        <h1>管理
            <small>order管理</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>管理</el-breadcrumb-item>
            <el-breadcrumb-item>order管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <!--查询表单-->
                <el-form :inline="true">
                    <el-form-item label="输入搜索">
                        <el-input v-model="searchMap.id" placeholder="订单编号/商品货号" class="filter-item"></el-input>
                    </el-form-item>
                    <el-form-item label="收货人">
                        <el-input v-model="searchMap.totalMoney" placeholder="收货人姓名/手机号码"
                                  class="filter-item"></el-input>
                    </el-form-item>
                    <el-form-item label="提交时间">
                        <el-input v-model="searchMap.createTime" type="Date" placeholder="请选择时间"
                                  class="filter-item"></el-input>
                    </el-form-item>

                    <el-button class="dalfBut" @click="fetchData()">查询</el-button>
                </el-form>
            </div>

            <div>
                <el-button class="dalfBut" @click="fetchData()">批量发货</el-button>
            </div>
            <el-table :data="tableData" border style="width: 100%">
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="id" label="订单编号" width="200"></el-table-column>
                <el-table-column prop="createTime" label="提交时间" width="200"></el-table-column>
                <el-table-column prop="username" label="用户账号" width="200"></el-table-column>
                <el-table-column prop="payMoney" label="订单金额" width="160"></el-table-column>
                <el-table-column prop="payType" label="支付方式" width="160"></el-table-column> <!--1、在线支付、0 货到付款-->
                <el-table-column prop="sourceType" label="订单来源" width="160"></el-table-column>
                <!--1:web，2：app，3：微信公众号，4：微信小程序  5 H5手机页面-->
                <el-table-column prop="orderStatus" label="订单状态" width="160"></el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button @click="findDetails(scope.row.id)" size="mini" type="primary" size="small">查看订单</el-button>
                        <el-button @click="dele(scope.row.id)" size="mini" type="danger" size="small">关闭订单</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="fetchData"
                        @current-change="fetchData"
                        :current-page.sync="currentPage"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="size"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </div>
            <!--<div class="add-form">

            </div>-->
        </div>
    </div>


</div>
</body>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script src="/js/elementui.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                tableData: [],
                currentPage: 1,
                total: 10,
                size: 10,
                searchMap: {}
            }
        },
        created() {
            this.fetchData();
        },
        methods: {
            fetchData() {
                axios.post(`/order/findPage.do?page=${this.currentPage}&size=${this.size}`, this.searchMap).then(response => {
                    this.tableData = response.data.rows;
                    this.total = response.data.total;
                });
            },
            findDetails(id) {
                location.href=`/order/orderItem.html?id=${id}`;
            },
            dele(id) {
                this.$confirm('确定要删除此记录吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get(`/order/delete.do?id=${id}`).then(response => {
                        this.fetchData(); //刷新列表
                    })
                })
            }
        }
    })
</script>
</html>
